/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-09-02 14:31:06
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-09-04 15:14:05
 * @FilePath: \linePatrol\vue-element-plus-admin\src\api\securcheck\LedgerMessage.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import service from '@/axios/http'
import { TableIResponse } from '@/utils/Api'
import { UserAreaTree, UserArea, UserLedgerListType, AddUserGasdev } from './type'
export class SecurCheckLedgerApi {
  //查询用户片区结构树
  async GetUserAreaTree(params: any): Promise<UserAreaTree[]> {
    const result = (await service.get('/api/securcheck/tbArea/TbAreaTree', {
      params
    })) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }

  //新增用户片区
  async AddUserArea(data: UserArea): Promise<boolean> {
    const result = (await service.post('/api/securcheck/tbArea', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }

  //修改用户片区
  async EditUserArea(data: UserArea): Promise<boolean> {
    const result = (await service.put('/api/securcheck/tbArea', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //删除用户片区
  async DeletUserArea(ids: number | undefined): Promise<boolean> {
    const result = (await service.delete(`/api/securcheck/tbArea/${ids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询用户片区详情
  async GetUserAreaById(id: string | undefined): Promise<UserLedgerListType> {
    const result = (await service.get(`/api/securcheck/tbArea/${id}`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return {}
    }
  }
  //查询用户台账列表
  async GetUserLedgerList(params: any): Promise<TableIResponse<UserLedgerListType[]>> {
    const result = (await service.get('/api/securcheck/tbUserLedger/list', {
      params
    })) as unknown as any
    return result
  }
  //查询用户台账列表详情
  async GetUserLedgerById(uuid: string | undefined): Promise<UserLedgerListType> {
    const result = (await service.get(`/api/securcheck/tbUserLedger/${uuid}`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return {}
    }
  }
  //新增用户台账列表
  async AddUserLedger(data: UserLedgerListType): Promise<boolean> {
    const result = (await service.post('/api/securcheck/tbUserLedger', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改用户台账列表
  async EditUserLedger(data: UserLedgerListType): Promise<boolean> {
    const result = (await service.put('/api/securcheck/tbUserLedger', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }

  //删除用户台账列表
  async DeletUserLedger(uuids: string): Promise<boolean> {
    const result = (await service.delete(`/api/securcheck/tbUserLedger/${uuids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询燃气设备列表
  async GetUserGasdevDetail(uuid: string | undefined): Promise<UserLedgerListType> {
    const result = (await service.get(`/api/securcheck/tbUserGasdev/${uuid}`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return {}
    }
  }
  //查询燃气设备详情
  async GetUserGasdev(params: any): Promise<TableIResponse<any[]>> {
    const result = (await service.get('/api/securcheck/tbUserGasdev/list', {
      params
    })) as unknown as any
    return result
  }
  //删除用户片区
  async DeletUserGasdev(uuids: number | undefined): Promise<boolean> {
    const result = (await service.delete(`/api/securcheck/tbUserGasdev/${uuids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //新增关联用气设备
  async AddUserGasdev(data: AddUserGasdev): Promise<boolean> {
    const result = (await service.post(
      '/api/securcheck/tbUserGasdev/addList',
      data
    )) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
}
export default new SecurCheckLedgerApi()
